import { createStore, applyMiddleware } from 'redux'
import reducer from './reducer'
import thunk from 'redux-thunk'
import logger from 'redux-logger'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

//对原有的reducer进行处理 生成 持久化的reducer
let persistReducers = persistReducer({ key: 'root', storage }, reducer)

//创建一个唯一的store
let store = createStore(persistReducers, applyMiddleware(thunk, logger))

//对唯一的store进行持久化处理，生成持久化的store
let persistor = persistStore(store);

export {
    store,
    persistor
}